package com.jiang.demo.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.jiang.demo.common.enums.GenderEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.NotBlank;
import java.time.LocalDate;
import java.util.List;


@ApiModel(value = "User2Entity")
@Data
@EqualsAndHashCode(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "user2", autoResultMap = true)
public class User2Entity extends BaseEntity {

    @TableId(value = "id", type= IdType.AUTO)
    @ApiModelProperty("主键ID")
    private Long id;

    @NotBlank(message = "用户名不能为空")
    @ApiModelProperty("用户名")
    private String name;

    @ApiModelProperty("年龄")
    private int age;

    @ApiModelProperty(value = "性别", notes = "com.jiang.demo.common.enums.GenderEnum")
    private GenderEnum gender;

    @TableField(typeHandler = JacksonTypeHandler.class)
    @ApiModelProperty("标签")
    private List<String> tags;

    @TableField(typeHandler = JacksonTypeHandler.class)
    @ApiModelProperty("标签ID")
    private List<Long> tagIds;

    @TableField(typeHandler = JacksonTypeHandler.class)
    @ApiModelProperty("地址列表")
    private List<Address> addressList;

    @TableField(typeHandler = JacksonTypeHandler.class)
    @ApiModelProperty("拓展信息")
    private Ext ext;

    @ApiModelProperty
    private LocalDate birth;


    @ApiModel(value = "Address")
    @Data
    public static class Address{

        @ApiModelProperty("id")
        private Long id;

        @ApiModelProperty("地址")
        private String address;
    }

    @ApiModel(value = "Ext")
    @Data
    public static class Ext{

        @ApiModelProperty("ext1")
        private String ext1;

        @ApiModelProperty("ext2")
        private String ext2;

        @ApiModelProperty("extList")
        private List<String> extList;
    }
}
